<?php include _include(APP_PATH.'view/htm/header.inc.htm');?>

<div class="card">
    <div class="card-header"><?php echo lang('move_thread');?></div>
    <div class="card-body ajax-body">
        <form action="<?php echo url("mod-move");?>" method="post" id="mod_move_form">
            <div class="Form f-15">
                <div class="Form-group">
                    <label><?php echo lang('total');?>：</label>
                    <div>
                        <span class="total font-weight-bold text-danger"></span> <?php echo lang('piece');?>
                    </div>
                </div>
                <div class="Form-group">
                    <label><?php echo lang('choose_move_forum');?>：</label>
                    <div>
                        <select class="custom-select" name="newfid">
                            <?php echo form_options($forumarr, 0);?>
                        </select>
                    </div>
                </div>
                <div class="Form-group">
                    <button type="submit" class="Button Button--primary" data-loading-text="<?php echo lang('submiting');?>..."><?php echo lang('confirm');?></button>
                </div>
            </div>
        </form>
    </div>
</div>

<?php include _include(APP_PATH.'view/htm/footer.inc.htm');?>

<script ajax-eval="true">

// 接受传参
var args = args || {jmodal: null, callback: null, arg: null};
var jmodal = args.jmodal;
var callback = args.callback;
var arg = args.arg;
var jthreadlist = $(arg);  // .threadlist
var tidarr = jthreadlist.find('input[name="modtid"]').checked();

var jform = $('#mod_move_form');
var jsubmit = jform.find('button[type="submit"]');
var jcancel = jform.find('button[type="button"]');
var jnewfid = jform.find('select[name="newfid"]');
var jtotal = jform.find('span.total');
jtotal.text(tidarr.length);

jform.on('submit', function() {
    jform.reset();
    jsubmit.button('loading');
    var postdata = jform.serializeObject();
    postdata.tidarr = tidarr;
    postdata.newfid = jnewfid.val();
    $.xpost(jform.attr('action'), postdata, function(code, message) {
        if(code == 0) {
            jsubmit.button(message);
            setTimeout(function() {
                if(jmodal) jmodal.modal('dispose');
                if(callback) callback(message);
                window.location.reload();
            }, 1000);
        } else {
            alert(message);
            jsubmit.button('reset');
        }
    });
    return false;
});
jcancel.on('click', function() {
    if(jmodal) jmodal.modal('dispose');
});

</script>
